package com.wangzhy.financial.controller;

import java.util.List;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.framework.aspectj.lang.annotation.Log;
import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
import com.wangzhy.financial.domain.DeptYs;
import com.wangzhy.financial.service.IDeptYsService;
import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.framework.web.page.TableDataInfo;

/**
 * 部门预算Controller
 *
 * @author wangzhy
 * @date 2021-11-15
 */
@RestController
@RequestMapping("/financial/deptYs")
@Api(tags = "部门预算Controller")
public class DeptYsController extends BaseController
{
    @Autowired
    private IDeptYsService deptYsService;

    /**
     * 查询部门预算列表
     */
    @ApiOperation("查询部门预算列表")
    @PreAuthorize("@ss.hasPermi('financial:deptYs:list')")
    @GetMapping("/list")
    public TableDataInfo list(DeptYs deptYs)
    {
        startPage();
        List<DeptYs> list = deptYsService.selectDeptYsList(deptYs);
        return getDataTable(list);
    }

    /**
     * 导出部门预算列表
     */
    @ApiOperation("导出部门预算列表")
    @PreAuthorize("@ss.hasPermi('financial:deptYs:export')")
    @Log(title = "部门预算", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(DeptYs deptYs)
    {
        List<DeptYs> list = deptYsService.selectDeptYsList(deptYs);
        ExcelUtil<DeptYs> util = new ExcelUtil<DeptYs>(DeptYs.class);
        return util.exportExcel(list, "deptYs");
    }

    /**
     * 获取部门预算详细信息
     */
    @ApiOperation("获取部门预算详细信息")
    @PreAuthorize("@ss.hasPermi('financial:deptYs:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id)
    {
        return AjaxResult.success(deptYsService.selectDeptYsById(id));
    }

    /**
     * 新增部门预算
     */
    @ApiOperation("新增部门预算")
    @PreAuthorize("@ss.hasPermi('financial:deptYs:add')")
    @Log(title = "部门预算", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody DeptYs deptYs)
    {
        return toAjax(deptYsService.insertDeptYs(deptYs));
    }

    /**
     * 修改部门预算
     */
    @ApiOperation("修改部门预算")
    @PreAuthorize("@ss.hasPermi('financial:deptYs:edit')")
    @Log(title = "部门预算", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody DeptYs deptYs)
    {
        return toAjax(deptYsService.updateDeptYs(deptYs));
    }

    /**
     * 删除部门预算
     */
    @ApiOperation("删除部门预算")
    @PreAuthorize("@ss.hasPermi('financial:deptYs:remove')")
    @Log(title = "部门预算", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids)
    {
        return toAjax(deptYsService.deleteDeptYsByIds(ids));
    }
}
